home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / sregexpf / clsregex.h < prev    next >
C/C++ Source or Header  |  1998-05-28  |  1KB  |  53 lines

  1. #ifndef __REGEXP_H__
  2. #define __REGEXP_H__
  3.  
  4. #include <string>
  5.  
  6. #ifdef _UNICODE
  7.     typedef std::wstring str_t;
  8. #else
  9.     typedef std::string str_t;
  10. #endif
  11.  
  12. class regexp;
  13. class Regexp {
  14. public:
  15.     enum { NSUBEXP = 10 };
  16.  
  17.     Regexp();
  18.     Regexp(LPCTSTR exp, BOOL iCase = 0);
  19.     Regexp(const Regexp &r);
  20.     ~Regexp();
  21.  
  22.     const Regexp & operator=(const Regexp & r);
  23.  
  24.     void  SetRegExp(LPCTSTR exp, BOOL iCase = 0);
  25.     bool    Match(LPCTSTR s, long lStartPos);
  26.     int    SubStrings() const;
  27.     
  28.     str_t    operator[](unsigned int i) const;
  29.     int    SubStart(unsigned int i) const;
  30.     int    SubLength(unsigned int i) const;
  31.  
  32.     str_t    GetReplaceString(LPCTSTR source) const;
  33.  
  34.     str_t    GetErrorString() const;
  35.     short    GetErrorNumber() const;
  36.     bool    CompiledOK() const;
  37.  
  38. #if defined(_RE_DEBUG)
  39.     void Dump();
  40. #endif
  41.  
  42. private:
  43.     const TCHAR*    m_string;    /* used to return substring offsets only */
  44.     mutable str_t    m_sError;
  45.     regexp*            rc;
  46.  
  47.     void    ClearErrorString() const;
  48.     int    safeIndex(unsigned int i) const;
  49. };
  50.  
  51. #endif
  52.  
  53.